﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
using Enterprise.Model.OfficeDocument;
using Enterprise.Infrastructure;
namespace Enterprise.Data.OfficeDocument
{
    /// <summary>
    /// 公文数据操作
    /// </summary>
    public class OfficeDocData
    {
        /// <summary>
        ///  公文数据列表
        /// </summary>
        /// <returns></returns>
        public List<OfficeDocEntity> OfficeDocmentList()
        {
            List<OfficeDocEntity> list = new List<OfficeDocEntity>();
            string cmd = "Select * from OFFICE_DOCUMENT";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                OfficeDocEntity entity = new OfficeDocEntity();
                if (!Convert.IsDBNull(dr["ODID"])) entity.ODID = Convert.ToString(dr["ODID"]);
                if (!Convert.IsDBNull(dr["ODTYPE"])) entity.ODTYPE = Convert.ToString(dr["ODTYPE"]);
                if (!Convert.IsDBNull(dr["ODTYPEID"])) entity.ODTYPEID = Convert.ToInt32(dr["ODTYPEID"]);
                if (!Convert.IsDBNull(dr["ODFROMTIME"])) entity.ODFROMTIME = Convert.ToString(dr["ODFROMTIME"]);
                if (!Convert.IsDBNull(dr["ODFROMUSER"])) entity.ODFROMUSER = Convert.ToString(dr["ODFROMUSER"]);
                if (!Convert.IsDBNull(dr["ODCODE"])) entity.ODCODE = Convert.ToString(dr["ODCODE"]);
                if (!Convert.IsDBNull(dr["ODFROM"])) entity.ODFROM = Convert.ToString(dr["ODFROM"]);
                if (!Convert.IsDBNull(dr["ODCNAME"])) entity.ODCNAME = Convert.ToString(dr["ODCNAME"]);
                if (!Convert.IsDBNull(dr["ODRNAME"])) entity.ODRNAME = Convert.ToString(dr["ODRNAME"]);
                if (!Convert.IsDBNull(dr["ODCREMARK"])) entity.ODCREMARK = Convert.ToString(dr["ODCREMARK"]);
                if (!Convert.IsDBNull(dr["ODRREMARK"])) entity.ODRREMARK = Convert.ToString(dr["ODRREMARK"]);
                if (!Convert.IsDBNull(dr["ODFILES"])) entity.ODFILES = Convert.ToString(dr["ODFILES"]);
                if (!Convert.IsDBNull(dr["ODSTATE"])) entity.ODSTATE = Convert.ToInt32(dr["ODSTATE"]);
                if (!Convert.IsDBNull(dr["ODCHECKERS"])) entity.ODCHECKERS = Convert.ToString(dr["ODCHECKERS"]);
                if (!Convert.IsDBNull(dr["ODDEPTID"])) entity.ODDEPTID = Convert.ToInt32(dr["ODDEPTID"]);
                if (!Convert.IsDBNull(dr["ODUSERID"])) entity.ODUSERID = Convert.ToInt32(dr["ODUSERID"]);
                if (!Convert.IsDBNull(dr["ODCREATETIME"])) entity.ODCREATETIME = Convert.ToDateTime(dr["ODCREATETIME"]);
                if (!Convert.IsDBNull(dr["ODISPUBLIC"])) entity.ODISPUBLIC = Convert.ToInt32(dr["ODISPUBLIC"]);
                if (!Convert.IsDBNull(dr["ODPUBLICTIME"])) entity.ODPUBLICTIME = Convert.ToDateTime(dr["ODPUBLICTIME"]);
                if (!Convert.IsDBNull(dr["ODQSUSERS"])) entity.ODQSUSERS = Convert.ToString(dr["ODQSUSERS"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 公文数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void OfficeDocumentExecute(string cmd)
        {
            DbExecute.Execute(cmd);
        }

        /// <summary>
        /// 数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void OfficeDocumentExecute(string cmd, string item1, object item1Value, string item2, object item2Value)
        {
            DbExecute.ExecuteCommand(cmd, item1, item1Value, item2, item2Value);
        }

        /// <summary>
        /// 返回数据集合
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public DataSet ExcuteDataSet(string cmd)
        {
            return DbExecute.GetDataSet(cmd);
        }
    }
}
